import axios from 'axios';

const prefix = process.env.NODE_ENV === 'development' ? '/api' : '';
const create_comment = prefix + '/knowledge/comment/save';
const comment_list = prefix + '/knowledge/comment/list';

export default {
 createComment: function (parameters, callback, errorHandler) {
    axios.post(create_comment, {
        chapterId: parameters[0],
        comment: parameters[1],
      }).then((resp)=>{
        callback(resp.data);
    }).catch((resp)=>{
        errorHandler(resp);
    });
  },

  fetchCommentList: function (parameters, callback, errorHandler) {
    axios.get(comment_list, {
      params: {
        chapterId: parameters[0],
        pageNum: parameters[1],
        pageSize: parameters[2]
      }
    }).then(function (resp) {
      callback(resp.data.commentPageDTO);
    }).catch(function (resp) {
      errorHandler(resp);
    });
  }

}
